<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('物流对账单')" />
	<th:block th:include="include :: businessCSS" />
	<style>
        .main-content{position: relative;}
        .topbtns{position:fixed;top: 0;width: 100%;z-index: 9999;background-color: #fff;}
		.preservationBtn{padding: 10px;margin: 0;position: fixed;top: 0;z-index: 9999;background: #fff;width: 100%;}
		.preservationBtn input{font-size: 16px;background-color: rgb(80, 138, 238);color: #fff;border: none;padding: 5px 30px;border-radius: 5px;cursor: pointer;}
		/* .layui-border-box{height: 350px !important;}
		.layui-table-body{height: 240px !important;} */
		.layui-table-tool-temp{padding-right: 30px;}
        .getDetailUpload,.getDetailUpload2{cursor: pointer;}
        .layui-table-tool-self{display: none;}
        .listext th{background:#eee;color:#3366cc;}
        .listext th,.listext td{border:solid 1px #ddd;text-align:left;padding:10px;font-size:14px;}
        .importTable{empty-cells:show;border-collapse:collapse;border-spacing:0;}
	</style>
</head>
<body class="no-skin">
<div class="main-container" id="main-container">
	<div class="main-content">
	<form class="layui-form head-form">
        <div class="north">
            <th:block th:include="include :: business_btn" />
            <th:block th:include="include :: business_tp2('top')" />
        </div>
        <div style="width: 100%;height: 10px;background: #f6f6f6;"></div>
        <div>
            <table class="layui-hide" id="mjdhtable" lay-filter="mjtable"></table>
            <script type="text/html" id="zjtoolbar">
                <div style="padding: 16px;display: flex;justify-content: space-between;">
                    <div  style="font-weight: 700;font-size: 18px;">物流订单信息</div>
            		<div>
                        <button class="layui-btn layui-btn-normal dhicon" th:classappend="${enableEdit} == 1 ?'':'layui-btn-disabled'" type="button" th:disabled="${enableEdit} == 1 ?false:true" lay-event="addbtn" id="btn-sh">新增</button>
                        <button class="layui-btn layui-btn-normal dhicon" th:classappend="${enableEdit} == 1 ?'':'layui-btn-disabled'" type="button" th:disabled="${enableEdit} == 1 ?false:true" onclick="importBtn()" lay-event="import" id="import">物流商对账单导入</button>
                        <button class="layui-btn layui-btn-normal dhicon" th:classappend="${enableEdit} == 1 ?'':'layui-btn-disabled'" type="button" th:disabled="${enableEdit} == 1 ?false:true" lay-event="cutbtn" id="cutbtn">系统/对账金额转换</button>
                        <button class="layui-btn layui-btn-danger dhicon" th:classappend="${enableEdit} == 1 ?'':'layui-btn-disabled'" type="button" th:disabled="${enableEdit} == 1 ?false:true" lay-event="mjbtn_save" id="mjbtn-sh">删除</button>
                        <button class="layui-btn layui-btn-danger dhicon" th:classappend="${enableEdit} == 1 ?'':'layui-btn-disabled'" type="button" th:disabled="${enableEdit} == 1 ?false:true" lay-event="del_btn" id="del_btn-sh">删除未匹配信息</button>
            		</div>
            	</div>
            </script>
        </div>
        <div style="width: 100%;height: 10px;background: #f6f6f6;"></div>
        <div>
            <table class="layui-hide" id="xqdhtable" lay-filter="xqtable"></table>
            <script type="text/html" id="xqtoolbar">
                <div style="padding: 16px;display: flex;justify-content: space-between;">
                    <div  style="font-weight: 700;font-size: 18px;">物流订单详情</div>
                </div>
            </script>
        </div>
        <th:block th:include="include :: pageFooter" /> 
    </form>
	</div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: inlineJS" />
<script th:src="@{/dhecp/js/dh-toFixed.js}"></script>

<!-- 导入明细 -->
<div id="iTable" class="display_no">
    <table class="importTable listext" data-resizable-columns-id="demo-table">
        <tbody id="itbody"></tbody>
    </table>
</div>


<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + "logstics/fbaLogisticsReconcile",
    	prefix2 = ctx + "base/company";

	var fields = [[${fields}]];
    var fieldsList = [[${fieldsList}]];
	var fieldsHiddenList = [[${fieldsHiddenList}]];
	var moduleTable = [[${moduleTable}]];
	var enableEdit = [[${enableEdit}]];
	//导入字段
    var importFields =[[${importFields}]];
    //商品表格基础信息
	var gridColumns = [[${gridColumns}]];
	var gridColumnsZJ = [[${gridColumnsZJ}]];
	//判断是取对账数据还是付款数据  0 系统| 1 对账
    var isf = 0;

    //商品表格基础信息
    // 商品列表数据
    var List=[[${List}]];
    //子件列表数据
    var sonList=[[${sonList}]];
    var element,thStr;
    var fieldWidth = {},		//导入列表字段宽度
        filedRequired = {},		//导入列表必填字段
        dateFiled = [],			//导入列表日期字段
        hasNull = false;		//导入数据必填字段有空值
    $.each(gridColumnsZJ.dictionaryForPageFieldList,function(i,v){
        fieldWidth[v.fields] = v.fieldFrontWidth
        if(v.fieldFrontRequired)filedRequired[v.fields] = v.fieldName;
        if(v.fieldFrontType == 't_date')dateFiled.push(v.fields);
    })

    var tablecols1=[
        {type: 'numbers', fixed: 'left'}
        , {type: 'checkbox'}
        ,{align: 'center',field: 'logisticsOrderCode', title: '物流订单号', width: 200}
        ,{align: 'center',field: 'nameLogsticsWay', title: '物流方式名称', width: 100}
        ,{align: 'center',field: 'codeLogsticsServer', title: '物流服务商', width: 100}
        ,{align: 'center',field: 'nameLogsticsPattern', title: '物流名称', width: 100}
        ,{align: 'center',field: 'waybillNumber', title: '物流运单号', width: 100}
        ,{align: 'center',field: 'logisticsFeesSj', title: '系统物流运费', width: 100,totalRow:true}
        ,{align: 'center',field: 'logisticsFeesDz', title: '对账物流运费', width: 100,totalRow:true}
        ,{align: 'center',field: 'logisticsFeesFk', title: '付款物流运费', width: 100,edit:'text',totalRow:true}
        ,{align: 'center',field: 'logisticsFeesXs', title: '销售物流运费', width: 100,totalRow:true}
        ,{align: 'center',field: 'reconciliation', title: '利润状态', width: 100}
        ,{align: 'center',field: 'dzStatement', title: '对账情况', width: 100}
        ,{align: 'center',field: 'profit', title: '利润', width: 100}
        ,{align: 'center',field: 'reconciliationSt', title: '利润说明', width: 100,edit:'text'}
        ,{align: 'center',field: 'numBoxXt', title: '系统箱数', width: 100}
        ,{align: 'center',field: 'numBoxDz', title: '对账箱数', width: 110}
        ,{align: 'center',field: 'weightCalXt', title: '系统计重', width: 110}
        ,{align: 'center',field: 'weightCalDz', title: '对账计重', width: 110}
        ,{align: 'center',field: 'logisticsFreightXt', title: '系统计重运费', width: 100}
        ,{align: 'center',field: 'logisticsFreightDz', title: '对账计重运费', width: 100}
        ,{align: 'center',field: 'logisticsFreightFk', title: '付款计重运费', width: 100,edit:'text'}
        ,{align: 'center',field: 'materialSurchargeXt', title: '系统材质附加费', width: 150,hide: true}
        ,{align: 'center',field: 'priceProNameExtraPredictXt', title: '系统品名附加费', width: 150}
        ,{align: 'center',field: 'priceProNameExtraPredictDz', title: '对账品名附加费', width: 150}
        ,{align: 'center',field: 'priceProNameExtraPredictFk', title: '付款品名附加费', width: 150,edit:'text'}
        ,{align: 'center',field: 'priceClearanceOpeXt', title: '系统清关费', width: 100}
        ,{align: 'center',field: 'priceClearanceOpeDz', title: '对账清关费', width: 100}
        ,{align: 'center',field: 'priceClearanceOpeFk', title: '付款清关费', width: 100,edit:'text'}
        ,{align: 'center',field: 'fbaSpellTicketGuid', title: '拼票id', width: 100,hide: true}
        ,{align: 'center',field: 'codeCompany', title: '物流渠道账户编码', width: 100,hide: true}
        ,{align: 'center',field: 'nameCompany', title: '物流渠道账户名称', width: 100,hide: true}
        ,{align: 'center',field: 'type', title: '类型', width: 100,hide: true}
    ]

    var tablecols2=[
        ,{align: 'center',field: 'shipmentId', title: '订单', width: 200}
        ,{align: 'center',field: 'actualLogisticsFreight', title: '物流总费用', width: 200}
        ,{align: 'center',field: 'numBox', title: '箱数', width: 200}
        ,{align: 'center',field: 'weightReal', title: '实重', width: 200}
        ,{align: 'center',field: 'weightVol', title: '抛重', width: 200}
        ,{align: 'center',field: 'weightCal', title: '计重', width: 200}
        ,{align: 'center',field: 'priceTranCalWeightPredict', title: '计重费', width: 200}
        ,{align: 'center',field: 'surchargeMaterialMax', title: '附加材质', width: 200}
        ,{align: 'center',field: 'priceQualityExtraPredict', title: '材质附加费', width: 200}
        ,{align: 'center',field: 'numProName', title: '品名数', width: 200}
        ,{align: 'center',field: 'priceProNameExtraPredict', title: '品名附加费', width: 200}
        ,{align: 'center',field: 'priceClearanceOpe', title: '清关费', width: 200}
        ,{align: 'center',field: 'jettisonCoe', title: '抛货系数', width: 100}
        ,{align: 'center',field: 'aveBoxWeight', title: '平均箱重', width: 100}
    ]

   

	var $,layer,form,table,nid,noTable;

    layui.use(['laydate','form','layer','jquery','util','element','upload','table'], function () {
        $ = layui.$,layer = layui.layer,form = layui.form,laydate = layui.laydate,util = layui.util,element=layui.element,upload = layui.upload,table = layui.table;
        beforeInit();//表单初始化之前的动作集合
		//初始化操作
		headcom3()
        nid=$('#nid').val()
         // 保存按钮事件变化
        $(function(){
           $('.tp-save').attr('onclick','')
           $('.tp-save').attr('lay-filter','btn-edit')
           $('.tp-save').attr('lay-submit',true)
        })

        
        // 保存操作
        form.on('submit(btn-edit)', function(data){
            var is_return = false//是否中断保存
            if (listData1.length == 0){
                layer.msg("物流订单信息不允许为空,请核实后在操作！");
                return;
            }else {
                listData1.map((v,i)=>{
                    if(is_return) return;
                    if (v.logisticsFeesDz == null || v.logisticsFeesDz == ""){
                        is_return = true;
                        layer.msg("对账物流运费不允许为空,请核实后在操作！");
                        return;
                    }
                    if (v.numBoxDz == null || v.numBoxDz == ""){
                        is_return = true;
                        layer.msg("对账箱数不允许为空,请核实后在操作！");
                        return;
                    }
                    if (v.weightCalDz == null || v.weightCalDz == ""){
                        is_return = true;
                        layer.msg("对账计重不允许为空,请核实后在操作！");
                        return;
                    }
                    if (v.logisticsFreightDz == null || v.logisticsFreightDz == ""){
                        is_return = true;
                        layer.msg("对账计重运费不允许为空,请核实后在操作！");
                        return;
                    }
                    if (v.priceProNameExtraPredictDz == null || v.priceProNameExtraPredictDz == ""){
                        is_return = true;
                        layer.msg("对账品名附加费不允许为空,请核实后在操作！");
                        return;
                    }
                    if (v.priceClearanceOpeDz == null || v.priceClearanceOpeDz == ""){
                        is_return = true;
                        layer.msg("对账清关费不允许为空,请核实后在操作！");
                        return;
                    }
                    if (v.reconciliation == "利润不足"){
                        if(v.reconciliationSt == "" || v.reconciliationSt == null){
                            is_return = true;
                            layer.msg("利润状态:利润不足,利润情况不允许为空,请核实后在操作！");
                            return;
                        }
                    }
                })
            }
            if(is_return) return;
            $.modal.loading("正在处理中，请稍后...");
            $.post("/logstics/fbaLogisticsReconcile/editpost",{infoMap:JSON.stringify(data.field),infoItems:JSON.stringify(listData1),sonData:JSON.stringify(listData1)},function(res){
                $.modal.closeLoading()
			 	layer.msg(res.msg);
                if(res.code == 0){
                   window.location.href = '/logstics/fbaLogisticsReconcile/edit?nid=' + res.data;
                }
	        });
        });

        //监听单元格编辑
        table.on('edit(mjtable)', function(obj){
            var tr = obj.tr;
            var regular2 = /^[0-9]+(.[0-9]{0,2})?$/
            // 单元格编辑之前的值
            var oldtext = $(tr).find("td[data-field='"+obj.field+"'] div").text();
            let fxa = true;
            var msg = '';
            //判断是否数值匹配
            listData1.map((n,m)=>{
                if (fxa == false){
                    return
                }
                if(n.logisticsOrderCode == obj.data.logisticsOrderCode){
                    if (obj.field == "logisticsFeesFk"){
                        if (!regular2.test(obj.value) && obj.value != '') {
                            n[obj.field]  = oldtext;
                            fxa = false;
                            msg = '付款物流费用只允许输入两位小数点的正数,请核实后在操作!';
                            return
                        }
                    } else if (obj.field == "reconciliationSt"){
                        if (obj.value.length >250){
                            fxa = false;
                            n[obj.field]  = '';
                            msg = '利润说明不允许超过250个字符,请核实后在操作!';
                            return
                        }
                    }
                    upReconciliation(n);
                }
            })
            table.reload('mjdhtable', {data:listData1});
            if (!fxa){
                layer.msg(msg)
                return
            }
        });

        //单击选中行
        table.on('row(mjtable)', function(obj){
            var logisticsOrderCode = obj.data.logisticsOrderCode;
            if (obj.data.type == 0){
                $.get('/logstics/fbaLogisticsOrder/details',{logisticsOrderCode:logisticsOrderCode},function(res){
                    if (res.code == 0){
                        table.reload('xqdhtable', {data:res.data});
                    }
                })
            } else {
                table.reload('xqdhtable', {data:[]});
            }
        });

        var listData1=List ?List:[]
        var listData2=sonList ?sonList:[]
        // 初始化表格
        $.tablelist.init({
            elem: '#mjdhtable'
            ,data: listData1
            , page: false
            , even: true
            , limit: 10000
            , totalRow: true
            , cols: [tablecols1]
            , toolbar: '#zjtoolbar'
            , defaultToolbar: [{title: '列设置', layEvent: 'fieldSet', icon: 'layui-icon-set'}]
            , height: '320'
            , done: function (res, curr, count) {
                listData1 = table.cache.mjdhtable;//每次重载都赋值更新表缓存
            },success:function(a,b,c){
                    // console.log(a,b,c,9999)
            }
        });

        $.tablelist.init({
            elem: '#xqdhtable'
            ,data: []
            , page: false
            , even: true
            , limit: 10000
            , totalRow: false
            , cols: [tablecols2]
            , toolbar: '#xqtoolbar'
            , defaultToolbar: [{title: '列设置', layEvent: 'fieldSet', icon: 'layui-icon-set'}]
            , height: '320'
            , done: function (res, curr, count) {
                listData2 = table.cache.xqdhtable;//每次重载都赋值更新表缓存
            },success:function(a,b,c){
                // console.log(a,b,c,9999)
            }
        });



        //商品表格操作
        table.on('toolbar(mjtable)', function (obj) {
            var selectedObject=""
            sessionStorage.setItem('mjdata',JSON.stringify(table.cache.mjdhtable))
            table.cache.mjdhtable.map((v,i)=>{
                if(selectedObject){
                    selectedObject+=','+v.logisticsOrderCode
                }else{
                    selectedObject+=v.logisticsOrderCode
                }
            })
            switch (obj.event) {
                case 'addbtn':
                if (!$('#nameLogsticsServer').val()){
                    layer.msg("物流服务商为空,不允许新增！");
                    return;
                }
			    layer.open({
                	type: 2,
                	area: [($(window).width() - 200)+'px', ($(window).height() - 100)+'px'],
                	fix: false,//不固定
                	offset: '10%',//距离顶部
                	maxmin: true,//最大最小化
                	shade: 0.3,//遮罩
                	title: '物流订单信息',
                	content: "/logstics/fbaLogisticsReconcile/select2?pagetype=checkbox&by=direct&fmoduleTable="+"TP_FBALOGSTICSORDER"+"&selectedObject="+selectedObject+"&codereconcile="+$('#code').val()+"&nameLogsticsServer="+$('#nameLogsticsServer').val(),
                	btn: ['确定', '取消'],
                	shadeClose: true,// 弹层外区域关闭
                	yes: function(index, layero){
						var res = window["layui-layer-iframe" + index].callbackdata();
				        if(res.length > 0){
                            var logsticsServerNum = new Set();
                            $.each(res,function(i,v){
                                v.logisticsFeesSj=v.logisticsFeesSj
                                v.priceProNameExtraPredictFk=v.priceProNameExtraPredictXt
                                v.priceClearanceOpeFk=v.priceClearanceOpeXt
                                v.logisticsFreightXt=v.materialSurchargeXt + v.logisticsFreightXt
                                v.logisticsFreightFk=v.logisticsFreightXt
                                v.logisticsFeesFk=v.priceClearanceOpeXt + v.priceProNameExtraPredictXt + v.logisticsFreightXt
                                v.reconciliation = '无'
                                v.dzStatement = '无'
                                v.profit = 0
                                v.priceClearanceOpeDz = ''
                                v.materialSurchargeDz = ''
                                v.logisticsFreightDz = ''
                                v.reconciliationSt = ''
                                logsticsServerNum.add(v.codeLogsticsServer);
                                upReconciliation(v)
				        	})
                            if (logsticsServerNum.size > 1){
                                layer.msg("选择的物流服务商不允许多个,请核实数据后再操作!")
                                return
                            }
							layer.closeAll();
                            var mjdata=sessionStorage.getItem('mjdata')
                            if(mjdata){
                                mjdata=JSON.parse(mjdata)
                                let newall=[]
                                let endData = [];
                                var isdata=false
                                for (let i = 0; i < res.length; i++) {
                                    var isdata=false
                                    if (newall.indexOf(res[i].logisticsOrderCode) === -1) {
                                        for (let n = 0; n < mjdata.length; n++) {
                                            if (newall.indexOf(res[i].logisticsOrderCode) === -1) {
                                                if(res[i].logisticsOrderCode==mjdata[n].logisticsOrderCode){
                                                   isdata=true
                                                   endData.push(mjdata[n]);
                                                   newall.push(mjdata[n].logisticsOrderCode);
                                                }
                                            }
                                        }
                                        if(!isdata){
                                            endData.push(res[i]);
                                            newall.push(res[i].logisticsOrderCode);
                                        }
                                    }
                                }
                                table.reload('mjdhtable', {data:endData});
                            }else{
                                table.reload('mjdhtable', {data:res});
                            }
				        }else{
                            layer.msg("请选择数据");
                        }
                	}
                });

                   break;
    
                case 'mjbtn_save':
                    var objdata=table.checkStatus('mjdhtable')
                    objdata=objdata.data
                    listData1= table.cache.mjdhtable;
                    listData2 = table.cache.zjdhtable;
                    if(objdata.length>0){
                        objdata.forEach(item => {
                            listData1 = listData1.filter(items => items.logisticsOrderCode!= item.logisticsOrderCode);
                        });
                        table.reload('mjdhtable', {data:listData1});
                        table.reload('xqdhtable', {data:[]});
                    }else{
                        layer.msg("请选择数据");
                    }
                    break;
                case 'cutbtn':
                    var msg = isf == 0 ? "是否切换至对账数据?" : "是否切换至系统数据?";
                    $.modal.confirmCom(msg, function (result) {
                        isf = isf == 0 ? 1 : 0;
                        listData1 = table.cache.mjdhtable;
                        if (listData1.length > 0) {
                            listData1.forEach(v => {
                                if (isf == 0) {
                                    v.logisticsFreightFk = v.logisticsFreightXt
                                    v.priceProNameExtraPredictFk = v.priceProNameExtraPredictXt
                                    v.priceClearanceOpeFk = v.priceClearanceOpeXt
                                    v.logisticsFeesFk = Number(v.priceClearanceOpeXt) + Number(v.priceProNameExtraPredictXt) + Number(v.logisticsFreightXt)
                                } else {
                                    v.logisticsFreightFk = v.logisticsFreightDz
                                    v.priceProNameExtraPredictFk = v.priceProNameExtraPredictDz
                                    v.priceClearanceOpeFk = v.priceClearanceOpeDz
                                    v.logisticsFeesFk = Number(v.priceClearanceOpeDz) + Number(v.priceProNameExtraPredictDz) + Number(v.logisticsFreightDz)
                                }
                                upReconciliation(v)
                            });
                            table.reload('mjdhtable', {data: listData1});
                            layer.closeAll();
                        } else {
                            layer.msg("请新增数据");
                        }
                    })
                    break;
                case 'del_btn':
                    $.modal.confirmCom("是否删除未匹配信息?", function (result) {
                        listData1 = table.cache.mjdhtable;
                        if (listData1.length > 0) {
                            let listData2 = [];
                            listData1.forEach(v => {
                                if (v.logisticsFeesDz != 0  && v.logisticsFeesDz != undefined && v.logisticsFeesDz != NaN && v.logisticsFeesDz != ''){
                                    listData2.push(v);
                                }
                            });
                            table.reload('mjdhtable', {data: listData2});
                            layer.closeAll();
                        } else {
                            layer.msg("请新增数据");
                        }
                    })
                    break;
            };
        });
    });

    function  importBtn(){
        if (importFields) {
            thStr = '<tr><th><div style="width:30px;">序号</div></th>';
            $.each(importFields, function (i, val) {
                fieldWidth[val] = fieldWidth[val] ? fieldWidth[val] : 100;	//默认宽度100px
                thStr += '<th><div style="width:' + fieldWidth[val] + 'px;">' + i + '</div></th>';
            })
            thStr += '</tr>';
            layer.open({
                type: 1,
                area: ['400px', '230px'],
                fix: false,
                offset: '10%',
                maxmin: true,
                shade: 0.3,
                title: '导入',
                content: `
						<form enctype="multipart/form-data" class="mt20 mb10">
							<div class="col-xs-offset-1">
							<input type="file" id="file" name="file"/>
							<div class="mt10 pt5">
							<a onclick="$.tablelist.importTemplate('/logstics/fbaLogisticsReconcile/template?')" class="btn btn-default btn-xs"><i class="dhicon dh-file-excel-o"></i> 下载模板</a>
							</div>
							<font color="red" class="pull-left mt10">提示：仅允许导入“xls”或“xlsx”格式文件！</font>
							</div>
						</form>
												`,
                btn: ['<i class="dhicon dh-check"></i> 导入', '<i class="dhicon dh-remove"></i> 取消'],
                shadeClose: true,
                zIndex: 1000,
                btn1: function (index, layero) {
                    var file = layero.find('#file');
                    if (!file[0]['value']) {
                        layer.msg("请选择文件！");
                        return false;
                    }
                    var imRes = importListExcel(file[0], importFields,'fbaLogisticsOrder');
                }
            });
        } else {
            $.modal.alertWarning("后台未返回导入模板对象！");
        }
    }

    /*批量请求导入数据
     *tobj：导入数据对象
     *startNum：从第几条开始导入
     *oneImportNum：每次导入条数
     *allImportNum：总数据量
     *times：导入次数
     */
    function eachImport(tobj,startNum, oneImportNum, allImportNum, times, timeNum){
        var importObj = [];
        for(var i = startNum; i < allImportNum; i++){
            importObj.push(tobj[i]);
        }
        if (importObj.length ==0){
            layer.msg("导入数据为空,请核实后在操作!");
            showloadings(false);
            return;
        }
        $.ajaxSettings.async = false;
        listData1= table.cache.mjdhtable;
        showloadings(false);
        if(listData1.length>0){
            listData1.forEach(item => {
                let data = importObj.filter(items => items.waybillNumber== item.waybillNumber);
                if (data.length != 0){
                    item.logisticsFeesDz = data[0].logisticsFeesDz
                    item.numBoxDz = data[0].numBoxDz
                    item.weightCalDz = data[0].weightCalDz
                    item.logisticsFreightDz = data[0].logisticsFreightDz
                    item.priceProNameExtraPredictDz = data[0].priceProNameExtraPredictDz
                    item.priceClearanceOpeDz = data[0].priceClearanceOpeDz
                    upReconciliation(item)
                }
            });
            layer.msg("导入成功")
            setTimeout(function(){
                sessionStorage.setItem(moduleTable+'checkdata','')
                layer.closeAll();
                table.reload('mjdhtable', {data:listData1});
            }, 1000);
        }else{
            layer.msg("请新增物流订单数据!");
        }
    }

    //判断对账状态
    function upReconciliation(v){
        var fivePercent = Number(v.logisticsFeesSj) * 0.95;
        var percent = Number(v.logisticsFeesSj) * 1.05;
        //对账金额在正负百分之五范围内 对账准确
        if (fivePercent<=Number(v.logisticsFeesDz)  && Number(v.logisticsFeesDz)<= percent){
            v.dzStatement = "对账准确"
        }else {
            v.dzStatement = "对账不准确"
        }
        if (Number(v.logisticsFeesFk) <= Number(v.logisticsFeesXs)){
            v.reconciliation = "具有利润"
        } else {
            v.reconciliation = "利润不足"
        }
        v.profit = Number(v.logisticsFeesXs) - Number(v.logisticsFeesFk)
        v.profit = toFixed(v.profit,2);
    }

    /**
     * 回调弹框事件
     */
    function getMoreAfter(fieldsList,fields,tindex,fieldName,fieldSearchType,isSearch,isLayer,res) {//弹出框赋值回调
        if(fields=='nameLogsticsServer'){
            listData1 = [];
            table.reload('mjdhtable', {data:listData1});
        }
    }

</script>

</body>
</html>